Javatpoint Logo

working of system.out.println

By: sachin*** On: Sun Feb 16 22:16:14 IST 2014     Question Reputation0 Answer Reputation1 Quiz Belt Series Points0  1Blank User
I want to know the Meaning and working of System.out.println();
and reason how out variable call the method println() of printstream class ?
Up0Down

 
in System.out.println()

System is a class : "public final class System "
OUT is :" public final static PrintStream out = null; inside Sytem Class"

The "standard" output stream. This stream is already
open and ready to accept output data. Typically this stream
corresponds to display output.


println is a method in :"public class PrintStream extends FilterOutputStream"

this method u can use using OUT variable.
Image Created0Down

By: [email protected] On: Mon Feb 17 11:08:15 IST 2014 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :4Yes0No
 

inside the System class is the declaration of ‘out’ that looks like: ‘public static final PrintStream out’, and inside the Prinstream class is a declaration of ‘println()’ that has a method signature that looks like: ‘public void println()’.

it could be understand like...
import java.io.*;
class System{
public static PrintStream out=new PrintStream();
....
}

class PrintStream{
public void println(String s){...}
public void println(int i){...}
public void println(long l){...}
...
}
Image Created0Down

By: [email protected] On: Mon Feb 17 12:33:23 IST 2014 Question Reputation0 Answer Reputation392 Belt Series Points0 392User Image
Are You Satisfied :1Yes0No
Comments
Sir can u give me another example explaining this scenario.
By : [email protected] On: 2014-02-17 13:51:53  Question Reputation0 Answer Reputation1 Belt Series Points0
 1User
 
Sir can u give me another example explaining this scenario.
Image Created0Down

By: [email protected] On: Mon Feb 17 13:47:05 IST 2014 Question Reputation0 Answer Reputation1 Belt Series Points0 1User Image
Are You Satisfied :0Yes0No
 
println() method is used to print and pass the control to the new line. It is a method of PrintStream class. A method is called by the object. Therefore out is the object of the PrintStream class. System is a class that specifies hardware where output is to be produced(here). Thus, output is produced at console.Image Created0Down

By: [email protected] On: Mon Feb 17 17:18:28 IST 2014 Question Reputation0 Answer Reputation359 Belt Series Points0 359User Image
Are You Satisfied :0Yes0No